import com.android.chimpchat.ChimpChat;
import com.android.ddmlib.AndroidDebugBridge;

/**
 * Created by vps on 2016/6/8 0008.
 */
public class Test {

    public static void main(String[] args) {
        ChimpChat chimpChat = ChimpChat.getInstance();
        AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
        try {
           while (!bridge.hasInitialDeviceList()){
               Thread.sleep(100);
           }

        } catch (Exception ex) {

        }
        chimpChat.waitForConnection();
    }

//    public static void addd(String[] args) throws Exception {
//        ADBService adbService = new ADBServiceImpl();
//
//        List<String> udids = adbService.getConnectedDevicesUdid();
////        byte[] rawScreenshot = adbService.getScreenshot("deviceUdid", ADBScreenshotType.RAW);
////        Map configuration = adbService.getPropertiesForDevice("deviceUdid");
////
////        byte[] file = adbService.pullFile(deviceUdid, new ADBRemoteFile("/sdcard/testFile.txt"));
////        adbService.pushFile(deviceUdid, new File("pom.xml"), new ADBRemoteFile("/sdcard/pom.xml"));
////        adbService.sendKeys(deviceUdid, "testSendKeys via ADB");
//        for (String s : udids) {
//            System.out.println(s);
//
//        }
//        adbService.executeShellCommand(udids.get(0), "su cat /data/system/packages.xml");
//        List<ADBProcess> list = adbService.getProcessList(udids.get(0));
//        for (ADBProcess s : list) {
//            System.out.println(s.getName());
//
//        }
////        JadbConnection jadb = new JadbConnection();
////        List<JadbDevice> devices = jadb.getDevices();
////        while (true) {
////            for (JadbDevice d : devices) {
////                System.out.println("abc" + d);
////                //gsm.imei.id
////                //ro.ril.miui.imei
////                try {
////                    d.executeShell("su");
////                    InputStream is = d.executeShell("cat /data/system/packages.xml");
////                    System.out.println(IOUtils.toString(is, "UTF-8"));
////                } catch (Exception ex) {
////                    ex.printStackTrace();
////                }
//////                try {
//////                    InputStream is = d.executeShell("adb reboot  edl");
//////                    System.out.println(IOUtils.toString(is, "UTF-8"));
//////                } catch (Exception ex) {
//////                    ex.printStackTrace();
//////                }
////
////            }
////            Thread.sleep(500);
////        }
//        //u0_a180   25343 295   990520 69248 ffffffff b6e44ec4 S com.tencent.mm
//        //  u0_a180   25423 295   751588 53624 ffffffff b6e44ec4 S com.tencent.mm:push
//        // System.out.println(parserAppId("u0_a180   25343 295   990520 69248 ffffffff b6e44ec4 S com.tencent.mm"));
//    }

    public static String parserAppId(String str) {

        // Size
        int index = 0;
        while (str.charAt(index) != ' ') {
            index++;
        }
        while (str.charAt(index) == ' ') {
            index++;
        }

        // id
        int index2 = str.indexOf(" ", index);
        String appId = str.substring(index, index2);

        return appId;
    }
}
